package com.deer.wms.base.system.web.bill;

import com.deer.wms.base.system.model.bill.BillOutMes;
import com.deer.wms.base.system.model.bill.BillOutMesLog;
import com.deer.wms.base.system.service.bill.BillOutMesLogService;
import com.deer.wms.base.system.service.bill.BillOutMesService;
import com.deer.wms.common.core.controller.BaseController;
import com.deer.wms.common.core.domain.AjaxResult;
import com.deer.wms.common.core.page.TableDataInfo;
import com.deer.wms.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 李帅辰
 * @date 2021/6/24 18:00
 */
@Controller
@RequestMapping("/out/billOutMesLog")
public class BillOutMesLogController extends BaseController {
    private String prefix = "out/billOutMesLog";

    @Autowired
    private BillOutMesLogService billOutMesLogService;
    /**
     * 导出列表
     */
    @RequiresPermissions("out:billOutMesLog:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BillOutMesLog billOutMesLog) {
        List<BillOutMesLog> list = billOutMesLogService.findBillOutMesLogList(billOutMesLog);
        ExcelUtil<BillOutMesLog> util = new ExcelUtil<BillOutMesLog>(BillOutMesLog.class);
        return util.exportExcel(list, "MES交互日志");
    }
    /**
     * 导出列表
     */
    @RequiresPermissions("out:billOutMesLog:partExcel")
    @PostMapping("/partExcel")
    @ResponseBody
    public AjaxResult partExcel(@RequestParam  String ids) {
        List<BillOutMesLog> byIds = billOutMesLogService.findByIds(ids);
        // List<BillInSapDto> billInSapList = billInSapService.findBillInSapDtoList(billInSapCriteria);
        ExcelUtil<BillOutMesLog> util = new ExcelUtil<BillOutMesLog>(BillOutMesLog.class);
        return util.exportExcel(byIds, "MES交互日志");
    }

    @RequiresPermissions("out:billOutMesLog:view")
    @GetMapping()
    public String billOutMesLog() {
        return prefix + "/billOutMesLog";
    }

    //@RequiresPermissions("out:billOutMes:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo findList(BillOutMesLog billOutMesLog){
        startPage();
        List<BillOutMesLog> list = billOutMesLogService.findBillOutMesLogList(billOutMesLog);
        return getDataTable(list);
    }
    //打印
    @RequestMapping("print")
    public String print(@RequestParam String ids, Model model) {

        //System.out.println(ids);
        List<BillOutMesLog> byIds = billOutMesLogService.findByIds(ids);
        model.addAttribute("byids", byIds);


        return prefix + "/print";
    }

    @GetMapping("/detail")
    public String detail() {
        return prefix + "/detail";
    }

    @PostMapping("/findBillOutMesBybillOutMesId")
    @ResponseBody
    public BillOutMesLog findBillOutMesBybillOutMesId(Integer billOutMesLogId) {
        return billOutMesLogService.findBillOutMesLogById(billOutMesLogId);
    }
}
